package dockyin.action.pattern.template;

public abstract class AbstractCalculator {
    public final int calculate(String exp, String operator) {
        int[] params = split(exp, operator);
        return calculate(params[0], params[1]);
    }

    public abstract int calculate(int num1, int num2);

    public abstract String getOperator();

    private int[] split(String exp, String operator) {
        String[] params = exp.split(operator);

        int[] result = new int[params.length];
        for (int i = 0; i < params.length; i++) {
            result[i] = Integer.parseInt(params[i]);
        }

        return result;
    }
}
